#include "ADUGameOverScene.h"

Scene* GameOverLayer::createScene()
{
    // 'scene' is an autorelease object
    auto scene = Scene::create();
    
    // 'layer' is an autorelease object
    auto layer = GameOverLayer::create();

    // add layer as a child to scene
    scene->addChild(layer);

    // return the scene
    return scene;
}

// on "init" you need to initialize your instance
bool GameOverLayer::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !LayerColor::initWithColor(ccc4(0,0,0,0)))
    {
        return false;
    }

    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    float centerX = origin.x + visibleSize.width/2;
    float centerY = origin.y + visibleSize.height/2;
    auto gameOverLabel = Text::create("GAME OVER", "fonts/game_font.TTF", 30.0f);
    gameOverLabel->setColor(Color3B(255,255,255));
    gameOverLabel->setPosition(Vec2(centerX, centerY));

    _scoreLabelText = Text::create("Score", "fonts/game_font.TTF", 20.0f);
    _bestScoreLabelText = Text::create("Best ", "fonts/game_font.TTF", 20.0f);
    _scoreLabelText->setTextHorizontalAlignment(TextHAlignment::LEFT);
    _bestScoreLabelText->setTextHorizontalAlignment(TextHAlignment::LEFT);

    _scoreLabelText->setPosition(Vec2(centerX, centerY - 50.0f));
    _bestScoreLabelText->setPosition(Vec2(centerX, centerY - 80.0f));

    sprintf(_score, "%d", GameManager::getInstance()->getScore());
    sprintf(_bestScore, "%d", GameManager::getInstance()->getBestScore());

    _scoreText = Text::create(_score, "fonts/game_font.TTF", 20.0f);
    _bestScoreText = Text::create(_bestScore, "fonts/game_font.TTF", 20.0f);
    _scoreText->setPosition(Vec2(centerX + 50.0f, centerY - 50.0f ));
    _bestScoreText->setPosition(Vec2(centerX + 80.0f, centerY - 80.0f));
    
    this->addChild(gameOverLabel);
    this->addChild(_scoreLabelText);
    this->addChild(_bestScoreLabelText);
    this->addChild(_bestScoreText);
    this->addChild(_scoreText);
	
}

void GameOverLayer::update(float dt) {
	
}

